/*
 * @lc app=leetcode.cn id=495 lang=javascript
 *
 * [495] 提莫攻击
 */

// @lc code=start
/**
 * @param {number[]} timeSeries
 * @param {number} duration
 * @return {number}
 */
var findPoisonedDuration = function(timeSeries, duration) {
    let result = 0
    for (let index = 0; index < timeSeries.length + 1; index++) {
        const e = timeSeries[index];
        if (!index) {
            continue
        }
        if (!e) {
            result += duration
            continue
        }
        let interval = e - timeSeries[index - 1]
        if (interval < duration) {
            result += interval
        } else {
            result += duration
        }
    }
    return result
};
// @lc code=end

/* 

    这不就是节流函数吗
    但是感觉节流还是有点麻烦，直接暴力解了
    还不能纯暴力解，给的用例有点大

*/
